package com.bcxj.apidriver.service;

import com.bcxj.apidriver.client.ServiceDriverUserClient;
import com.bcxj.apidriver.client.ServiceMapClient;
import com.bcxj.internalcommon.dto.ApiDriverPointDTO;
import com.bcxj.internalcommon.dto.PointDTO;
import com.bcxj.internalcommon.dto.PointRequest;
import com.bcxj.internalcommon.dto.ResponseResult;
import com.bcxj.internalcommon.entity.Car;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * ClassName: PointService
 * Package: com.bcxj.apidriver.service
 * Description:
 *
 * @Author BCXJ
 * @Create 2024/11/2 23:16
 * @Version 1.0
 * @Since 1.0
 */
@Service
public class PointService {

    @Autowired
    private ServiceDriverUserClient serviceDriverUserClient;

    @Autowired
    private ServiceMapClient serviceMapClient;

    /**
     * 上传轨迹带你
     * @param apiDriverPointDTO
     * @return
     */
    public ResponseResult upload(ApiDriverPointDTO apiDriverPointDTO) {
        // 查询车辆信息
        ResponseResult<Car> carRes = serviceDriverUserClient.getCar(apiDriverPointDTO.getCarId());
        Car car = carRes.getData();

        // 上传轨迹
        String tid = car.getTid();
        String trid = car.getTrid();
        PointDTO[] point = apiDriverPointDTO.getPoint();

        PointRequest pointRequest = new PointRequest(tid, trid, point);
        ResponseResult responseResult = serviceMapClient.addPoint(pointRequest);
        return responseResult;
    }
}
